package org.hh.study.pooltest.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import thread.pool.core.executor.DynamicThreadPoolExecutor;

@RestController
public class TestController {

    @Autowired
    DynamicThreadPoolExecutor threadPoolExecutor;

    @GetMapping("/get")
    public Object get(){

        for (int i = 0; i < 600; i++) {
            int finalI = i;
            threadPoolExecutor.execute(()->{
                try {
                    Thread.sleep(1000L);
                    System.out.println(">>>>>>执行完了任务："+ finalI);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            });
        }
        return "ok";
    }
}
